<?php
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/js/jquery.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/bootstrap.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/global.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/index.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/Font-Awesome-3.2.1/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/bootstrap.min.css");
Yii::app()->clientScript->registerCss("CSS1","
    .cont_box img{
        height: 200px;
    }



");


?>
<style type="text/css">
    .main-box {

        height: 100%;
        left: 0;
        margin: 0 auto;
        position: absolute;
        top: 0;
        width: 100%;
        z-index: -1;
    }
    .morcon {
        height: 100px;
        margin: 245px 20px 20px;
        position: relative;
        text-align: center;
    }

    .morcon .reg {
        background: rgba(255, 255, 255, 0) none repeat scroll 0 0;
        border: medium none;
        color: #fff;
        font-size: 20px;
        left: 4%;
        position: absolute;
        top: 0;
    }
    .morcon .login {
        background: rgba(255, 255, 255, 0) none repeat scroll 0 0;
        border: medium none;
        color: #fff;
        display: block;
        font-size: 20px;
        left: 51%;
        position: absolute;
        top: 39%;
    }

    .wrap .header{
        width: 100%;
        position: relative;
        height: 300px;
    }
    .wrap .footer {
        height: 300px;
        position: relative;
        width: 100%;
    }


    .imgbg .box img {
        border-radius: 50%;
        height: 80%;
        left: 15px;
        position: absolute;
        top: 15px;
        width: 80%;
    }
    .wrap .header .hname {
        height: 200px;
        left: 170px;
        position: absolute;
        top: 144px;
        width: 200px;
    }
    .wrap .header .hname p{
        color: #0066b3;
        font-size: 20px;
    }
    .wrap .header .list {


        height: 80px;
        left: 25px;
        position: absolute;
        top: 25px;
        width: 80px;
    }
    .wrap .header .list a{
        color: #0066b3;
        font-size: 30px;
    }


    body{
        background: #f4f4f4 none repeat scroll 0 0;
    }
    .activity_list h3 {
        border-bottom: 1px solid #e2e1e1;
    }
    .scenic_sum h3 {
        color: #507fbd;
        font-size: 16px;
        margin-bottom: 1px;
        margin-top: 1px;
        min-height: 15px;
        padding-bottom: 22px;
    }
    .alert-danger, .alert-error {
        background-color: #f2dede;
        border-color: #eed3d7;
        color: #b94a48;
        text-align: center;
    }
    .fl{
        float: left;
    }
    .lbox{
        width: 30%;
    }
    .rbox{
        margin-left: 20px;
        margin-top:12px;
    }
    .rbox .fot{
        font-size: 16px;
    }
    .nav {
        background: rgb(249, 249, 249) none repeat scroll 0 0;
        border-top: 1px solid #ddd;
        bottom: 0;
        opacity: 0.9;
        padding: 6px 0 !important;
        position: fixed;
        width: 100%;
        height: 55px;
    }
    .nav .nav-box {
        color: #333;
        float: left;
        font-size: 14px;
        text-align: center;
        width: 33%;
        height: 100%;
    }
</style>

<div class="data"  >
    <header class="homeHder header">
        <a href="<?php echo Yii::app()->createUrl('user/index',array('openid'=>$openid)) ?>">
        <div class="hder_return flol">

                <i class="size fa fa-angle-left"></i>

        </div>
        </a>
        <div class="hder_logo">热门书籍</div>

    </header>
    <section class="wrap">
    <div class="container-fluid">
    <div class="row">
        <!-- Modal -->
        <div aria-hidden="true" aria-labelledby="linkModalLabel" role="dialog" tabindex="-1" id="linkModal-a">
            <div class="modal-body">
                <form>

                    <div class="form-group">
                        <p><small class="text-warning">输入书籍名称可对书籍进行搜索，当三个选项都为空时，按点击数排序。</small></p>
                        <label>年级</label>
                        <select class="form-control"  id="gid">
                            <option value="">请选择年级</option>
                            <?php if($grade){ ?>
                                <?php foreach($grade as $v){ ?>
                                    <option value="<?php echo $v->id ?>"><?php echo $v->title ?></option>
                                <?php } ?>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>班级</label>
                        <select class="form-control"  id="cid">
                            <option value="">请选择班级</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>书籍名称</label>
                        <input type="text" class="form-control" id="title">
                    </div>
                    <button class="btn btn-primary btn-block btn-lg" id="submitform" type="button">搜索</button>
                </form>
            </div>
        </div>
    </div>
    <div class="container-fluid">
    <div class="row">
    <ul class="activity bor" id="Xbox">
        <?php if($list){ ?>
            <?php foreach($list as $v){ ?>
        <li>
            <a class="img_type" href="<?php echo Yii::app()->createUrl('index/show',array('id'=>$v['id'],'openid'=>$openid)) ?>">
            <div class="scenic_sum activity_list clearfix">
                <h3><?php echo $v['title'] ?></h3>
                <div class="flol">
                    <div class="lbox fot fl">
                        <img src="<?php echo Yii::app()->params['webPath'].$v['thumb'] ?>"  class="img-thumbnail">
                    </div>
                    <div class="rbox fl">
                        <p class="fot">点击数：<span style="color: darkred;font-weight: 600"><?php echo intval($v['click']) ?></span></p>
                        <p class="fot">阅读数：<span style="color: darkgreen;font-weight: 600"><?php echo intval($v['people']) ?></span></p>
                        <p class="fot">喜欢数：<span style="color: darkblue;font-weight: 600"><?php echo intval($v['good']) ?></span></p>
                    </div>
                </div>
            </div>
            </a>
        </li>
            <?php } ?>
        <?php }else{ ?>
        <li>
            <div class="alert alert-error" style="" id="alt">
                暂无任何数据
            </div>
        </li>
        <?php } ?>
    </ul>
    <div class="alert alert-info" style="text-align: center; display: none;" id="loadings">
        <i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;正在加载中...
    </div>

    <div class="alert alert-error" style="display: none;" id="alt">
        没有更多啦！
    </div>
    </div>
        <br>
        <br>
        <br>
        <br>
    </div>

<!--    <nav class="nav">-->
<!--        <a href="--><?php //echo Yii::app()->createUrl('index/list1',array('openid'=>$openid)) ?><!--" class="">-->
<!--            <div class="nav-box">-->
<!--                <i class="fa fa-book"></i>书目-->
<!--            </div>-->
<!--        </a>-->
<!--        --><?php //if($user_info->role==2){ ?>
<!--            <a href="--><?php // echo Yii::app()->createUrl('user/child',array('openid'=>$openid)); ?><!--" class="">-->
<!--                <div class="nav-box">-->
<!--                    <i class="fa fa-user"></i>我的孩子-->
<!--                </div>-->
<!--            </a>-->
<!--        --><?php //}else{ ?>
<!--            <a href="--><?php // echo Yii::app()->createUrl('user/student',array('openid'=>$openid)); ?><!--" class="">-->
<!--                <div class="nav-box">-->
<!--                    <i class="fa fa-users"></i>我的学生-->
<!--                </div>-->
<!--            </a>-->
<!--        --><?php //} ?>
<!--        <a href="--><?php //echo Yii::app()->createUrl('user/index',array('openid'=>$openid)); ?><!--" class="">-->
<!--            <div class="nav-box">-->
<!--                <i class="fa fa-home"></i>个人中心-->
<!--            </div>-->
<!--        </a>-->
<!--    </nav>-->


    <script type="text/javascript">
        $(function(){
            $("#gid").change(function() {
                loadClass($("#gid").val());
            });
            function loadClass(gid) {
                $.ajax({
                    url: '<?php echo Yii::app()->createAbsoluteUrl("index/loadClass"); ?>'+ 'gid/' +gid,
                    type: 'POST',
                    dataType: 'html',
                    success: function(msg) {
                        if(msg){
                            msg = '<option value="">请选择班级</option>'+msg;
                            $("#cid").html(msg);
                        }else{
                            $("#cid").html('<option value="">请选择班级</option>');
                        }

                    }
                });
            }
        });





        $(function(){
            var currentPage = 0;
            var isloading = false;
            var lock = false;
            $("#submitform").click(function(){
                lock = true;
                $(this).addClass('disabled');
                $(this).html('<i class="fa fa-refresh fa-spin"></i>搜索');
                var gid = $("#gid").val();
                var cid = $("#cid").val();
                var title = $("#title").val();
                $.ajax({
                    url:'<?php echo $this->createUrl('ajaxBodyHot') ?>',
                    type : 'GET',
                    data:{
                        gid:gid,
                        cid:cid,
                        title:title
                    },
                    dataType:'html',
                    success : function (data,response,status) {
                        if(data){
                            lock = false;
                            isloading = false;
                            currentPage = 0;
                            $('#Xbox').html(data);
                            $("#submitform").removeClass('disabled');
                            $('#alt').hide();
                            $("#submitform").html('搜索');
                        }else{
                            $('#Xbox').html(data);
                            lock = false;
                            isloading = false;
                            currentPage = 0;
                            $("#submitform").removeClass('disabled');
                            $('#alt').hide();
                            $("#submitform").html('搜索');
                        }
                    }
                });
            });




            $(window).scroll(function(){
                var gid = $("#gid").val();
                var cid = $("#cid").val();
                var title = $("#title").val();
                if($(window).scrollTop() + 100 >= $(document).height() - $(window).height()){
                    if (isloading == true){  //如果loading为真 则return false;
                        return false;
                    }
                    currentPage = currentPage + 1;
                    isloading = true; //为真了
                    $.ajax({
                        url:'<?php echo $this->createUrl('ajaxHot') ?>',
                        type : 'GET',
                        data:{
                            page:currentPage,
                            gid:gid,
                            cid:cid,
                            title:title
                        },
                        dataType:'html',
                        beforeSend : function() {
                            $('#loadings').show();
                            isloading = true;
                        },
                        success : function (data,response,status) {
                            if(data){
                                $('#Xbox').append(data);
                                isloading = false;
                                $('#loadings').hide();
                            }else{
                                isloading = true;
                                $('#loadings').hide();
                                $('#alt').show();
                            }
                        }
                    });
                }
            });

        });
    </script>


    </div>
    </section>
</div>

